﻿/*
* ========================================================================
* 类说明：
*   
* 
* 作者：HGS   时间：2024/11/27 13:19:57
* 
* 修改者：         时间：           
* 修改说明：
* ========================================================================
*/

using EasyTest.Shared.EnumType;
using EasyTest.Shared.TestAttribute;
using EasyTest.Shared.外部访问;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using ZLGCANoptimize.方法;

namespace ZLGCANoptimize
{
    public class AVSV新
    {
        [ExposedMethodAttribute("")]
        public bool 打开AVSV(int 通道, out string 信息)
        {
            信息 = string.Empty;
            try
            {
                List<CanCmdModel> cmdList = new List<CanCmdModel>();
                cmdList.Add(new CanCmdModel() { Id = 0x1F5, cmd = "00 00 00 02 00 00 00 00" });
                cmdList.Add(new CanCmdModel() { Id = 0x1A9, cmd = "00 00 00 00 0A 00 00 00" });
                CanReadRequestModel requestModel = new CanReadRequestModel();
                requestModel.Channel = (ushort)通道;
                requestModel.IsClearCache = false;
                requestModel.IsDecode = false;
                requestModel.DecodeLevel = "62";
                requestModel.CmdList = cmdList;
                requestModel.SendCmdTimeSpan = 50;
                requestModel.MaxSendCount = 3;
                requestModel.AutoParse = false;
                requestModel.IsVerifyDid = false;
                requestModel.RequestMode = CanRequestMode.仅发送;

                var 发送响应 = 数据.发送指令(requestModel);
                if (发送响应.Success == false)
                {
                    信息 = 发送响应.ErrorMessage;
                    return false;
                }

                信息 = "打开AVSV成功";
                return true;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
               // LogHelper.Error($"[AVSV.打开AVSV]异常，{ex.Message}，{ex.StackTrace}");
                eLog.AddLog($"[AVSV.打开AVSV]异常，{ex.Message}，{ex.StackTrace}", eMsgType.Error);
            }
            return false;
        }
        [ExposedMethodAttribute("")]
        public bool 关闭AVSV(int 通道, out string 信息)
        {
            信息 = string.Empty;
            try
            {
                List<CanCmdModel> cmdList = new List<CanCmdModel>();
                cmdList.Add(new CanCmdModel() { Id = 0x1F5, cmd = "00 00 00 01 00 00 00 00" });
                cmdList.Add(new CanCmdModel() { Id = 0x1A9, cmd = "00 00 00 00 0A 00 00 00" });
                CanReadRequestModel requestModel = new CanReadRequestModel();
                requestModel.Channel = (ushort)通道;
                requestModel.IsClearCache = false;
                requestModel.IsDecode = false;
                requestModel.DecodeLevel = "62";
                requestModel.CmdList = cmdList;
                requestModel.SendCmdTimeSpan = 50;
                requestModel.MaxSendCount = 3;
                requestModel.AutoParse = false;
                requestModel.IsVerifyDid = false;
                requestModel.RequestMode = CanRequestMode.仅发送;

                var 发送响应 = 数据.发送指令(requestModel);
                if (发送响应.Success == false)
                {
                    信息 = 发送响应.ErrorMessage;
                    return false;
                }

                信息 = "关闭AVSV成功";
                return true;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
              //  LogHelper.Error($"[AVSV.关闭AVSV]异常，{ex.Message}，{ex.StackTrace}");
                eLog.AddLog($"[AVSV.关闭AVSV]异常，{ex.Message}，{ex.StackTrace}", eMsgType.Error);
            }
            return false;
        }
    }
}
